/**
 * Creater with IntelliJ IDEA.
 * Description:
 * User: 86152
 * Dae: 2022-07-27
 * Time: 17:12
 */
class SingleAton  {//懒汉模式,需要的时候才创建实例
    private static SingleAton instance = null;
    private SingleAton(){};
    public static SingleAton getInstanceA() {
        if(instance==null) {
            synchronized (SingleAton.class) {
                if (instance == null) {
                    instance = new SingleAton();
                }
                return instance;
            }
        }
    }
}
class Singleton {//饿汉模式，上来就创建
    private static Singleton instance = new Singleton();
    private Singleton() {};//防止再创建实例
    public static Singleton getInstance() {
        return instance;
    }
}
public class demo4 {
    public static void main(String[] args) {

    }
}
